<?php
###############   COPYLEFT GPLv3 LICENSE   ###############
##
## JFX Version 0.2.9
## Website Management Software
## www.jfxcms.com
##
## Copyright 2009 GPLv3 - http://www.opensource.org/licenses/gpl-3.0.html
##
## Anthony Gallon
## oi_antz@hotmail.com
##
## Permission is hereby granted to any person having a copy of this software
## to freely use and modify as required so long as the copyright notices
## and branding remain intact.
##
## Full license details available at http://www.jfxcms.com/license
##
###############   COPYLEFT GPLv3 LICENSE   ###############

class JFX_Theme_Default extends JFX_Theme
{
    public $keyname = 'default';
    public $title = 'Default Theme';
    public $version = '0.2.9';

    public function __construct(){
        parent::__construct();
    }
    
    public function parseMenuTemplate($menuObj){
        $depth = $menuObj->get('parentDepth');
        $content = '';
        switch($depth){
            case '0':
                // root
                $content .= '<div id="accordion">:|items|:</div>';
            break;
            case '1':
                $content .= '<h3><a href="#" id="jfx-leftcol-menu-'.$menuObj->get('keyname').'">'.$menuObj->get('title').'</a></h3><div>:|items|:</div>';
            break;
            case '2':
                $content .= '<h4>'.$menuObj->get('title').'</h4>';
                if(count($menuObj->getItems())>0) $content .= '<ul>:|items|:</ul>';
            break;
            case '3':
                $content .= '<li class="'.$menuObj->get('class').'" id="'.$menuObj->get('id').'">
                    <a href="'.$menuObj->get('url').'">
                    <img src="'.$menuObj->get('icon').'" alt="" />'.$menuObj->get('title').'</a></li>';
            break;
        }


        return $content;
        
    }


    public function implodeErrors($errors){
        if(count($errors)==0) return '';
        $retVal = '<div class="jfxt-error-messages"><div class="jfxt-error-messages-inner">';
        $retVal .= '<ul><li>'.implode('</li><li>', $errors).'</li></ul>';
        $retVal .= '</div></div>';
        return $retVal;
    }

    public function implodeSuccesses($succ){
        if(count($succ)==0) return '';
        $retVal = '<div class="jfxt-success-messages"><div class="jfxt-success-messages-inner">';
        $retVal .= '<ul><li>'.implode('</li><li>', $succ).'</li></ul>';
        $retVal .= '</div></div>';
        return $retVal;
    }


    public function parseBreadcrumbTemplate($breadcrumbObj){
        $bc = '';
        if($breadcrumbObj->get('icon')!==''){
            $icon = '<img src="'.$breadcrumbObj->get('icon').'" alt="" />';
        }else{
            $icon = '';
        }
        if($breadcrumbObj->get('current')===false){
            $bc .= $icon.'<a href="'.$breadcrumbObj->get('url').'" class="'.$breadcrumbObj->get('class').'" id="'.$breadcrumbObj->get('id').'">'.
            $breadcrumbObj->get('title').'</a>';
        }else{
            $bc .= '<span class="current">'.$breadcrumbObj->get('title').'</span>';
        }
        return $bc;
    }


    public function serve($request){
        /*
        if(post('logdata')!==''){
            $fh = fopen($this->dirname.'/logdata.txt', 'w');
            fwrite($fh, $_POST['logdata']);
            fclose($fh);
            exit;
        }*/
        parent::serve($request);
    }


}